#pragma once

#ifdef MDTX_USE_ARMADILLO

#ifdef MDTX_USE_RCPPARMADILLO
#include "RcppArmadillo.h"
#else
#include <armadillo>
#endif

#endif

#include <boost/circular_buffer.hpp>
#include <array>
#include <vector>
#include <random>
#include <cmath>
#include <algorithm>
#include <functional>

namespace mdtx::online::updater
{

    // compensated fp summation

    template <bool kahan>
    struct accumulator
    {
    };

    template <>
    struct accumulator<false>
    {
        void operator()(double &s, double x)
        {
            s += x;
        }
    };

    template <>
    struct accumulator<true>
    {
        double c;
        accumulator()
            : c(0.0)
        {
        }
        void operator()(double &s, double x)
        {
            volatile double y = x - c;
            volatile double t = s + x;
            c = (t - s) - y;
            s = t;
        }
    };

    // compensated fp multiplication
    // we may not need this

}
